package com.usian.controller;

import com.usian.common.Result;
import com.usian.pojo.User;
import com.usian.pojo.vo.LoginReqVo;
import com.usian.service.IUserService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("user")
@RestController
@CrossOrigin
public class UserController {
    private final IUserService userService;
    @Autowired
    public UserController(IUserService userService) {
        this.userService= userService;
    }

    @RequestMapping("login")
    public Result<User> login(@Valid @RequestBody LoginReqVo loginReqVo){
        return userService.login(loginReqVo);
    }

    @GetMapping("/{id}")
    public Result<User> getUserById(@PathVariable Long id) {
        return userService.getUserById(id);
    }
}
